<script lang="ts">
import { defineComponent } from "vue";
import { AppData } from "@/utils/app";

export default defineComponent({
  props: {
    retract: Boolean,
    url: String,
    zIndex: { type: Number, default: 94 },
  },
  setup() {
    return { topBarHeight: AppData.rectData.topBarHeight };
  },
});
</script>

<template>
  <view
    class="nav-bg"
    :style="{
      height: retract ? `${topBarHeight}px` : '',
      zIndex: retract ? zIndex : '',
    }"
  >
    <image class="nav-bg-img" v-if="url" :src="url" mode="widthFix" />
    <slot v-else />
  </view>
</template>

<style lang="scss">
.nav-bg {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  background-color: #ffffff;
  overflow: hidden;

  .nav-bg-img {
    display: block;
    width: 100%;
  }

  .nav-bg-cover {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
  }
}
</style>